package references

import (
	"go_gvm_mini/instructions/base"
	"go_gvm_mini/rtda"
)

type ARRAY_LENGTH struct {
	base.NoOperandsInstruction
}

func (al *ARRAY_LENGTH) Execute(jFrame *rtda.JFrame) {
	stack := jFrame.OperandStack()
	arr := stack.PopRef()
	if arr == nil {
		panic("java.lang.NullPointerException")
	}
	arrLen := arr.ArrayLength()
	stack.PushInt(arrLen)
}
